<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="./vue2.js"></script>
<body>
    <div id="box">
        <child v-if="status"></child>
    </div>
    <script>
        Vue.component('child',{
            data(){
                return{
                    time:1000
                }
            },
            template:`<div>{{time}}</div>`,
            created(){
                let id=null
            },
            mounted(){
                this.id= setInterval(()=>{
                    this.time--
                    console.log('倒计时');
                },1000)
            },
            destroyed(){
                clearInterval(this.id)
            }
        })
      let vm=  new Vue({
            el:'#box',
            data:{
                status:true
            }
        })
    </script>
</body>
</html>